<script setup lang="ts">
import { onMounted } from 'vue'
import TheHeader from './components/TheHeader.vue'
import TheFooter from './components/TheFooter.vue'
import LoginModal from './components/LoginModal.vue'
import { useUserStore } from './store/user'

const userStore = useUserStore()

onMounted(() => {
  // 检查登录状态
  userStore.checkLogin()
})
</script>

<template>
  <div class="app">
    <the-header />
    <main class="main-content">
      <router-view v-slot="{ Component }">
        <keep-alive v-if="$route.meta.keepAlive">
          <component :is="Component" />
        </keep-alive>
        <component :is="Component" v-else />
      </router-view>
    </main>
    <the-footer />
    <login-modal />
  </div>
</template>

<style>
/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  line-height: 1.5;
  background-color: #f5f7fa;
}

a {
  text-decoration: none;
  color: #409eff;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

.main-content {
  min-height: calc(100vh - 60px - 180px); /* 减去header和footer的高度 */
}
</style>
